<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {

    //管理登录页面
    public function index(){
        $this -> display();
    }
    //管理员登录
    public function login(){
        $account = I('post.account','','htmlspecialchars');
        $pwd = I('post.pwd','','htmlspecialchars');
        if(empty($account) || empty($pwd)){
            $this -> error('登录帐号或密码不能为空',U('/Home/Index/index'));
            return;
        }
        $c_account = C('account');
        $c_pwd = md5(C('pwd'));
        if($c_account == $account && $c_pwd == md5($pwd)){
            $_SESSION['lieying_login'] = time();
            $this ->success('登录成功!', U('/Home/Install/index'));
            return;
        }
        $this -> error('登录帐号或密码错误',U('/Home/Index/index'));
    }

    public function logout() {
        session_unset();
        session_destroy();
        unset($_SESSION);
        $this ->redirect('/Home/Index/index',array());
    }
}